package com.xwltz.main;

import com.xwltz.entity.Account;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class RunMain1 {
    public static void main(String[] args) {
        InputStream inputStream = RunMain1.class.getClassLoader().getResourceAsStream("config.xml");
        SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
        SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();

        String accountMapper = "com.xwltz.mapper.AccountMapper.insertAccount";
        Account account = new Account();
        account.setUsername("com.xwltz");
        account.setPassword("123456");
        account.setAge(22);
        sqlSession.insert(accountMapper, account);
        sqlSession.commit();

        sqlSession.close();
    }
}
